<?

session_name("WIMON");
session_start();

function kill_session() {
	session_unset();
	session_destroy();
	$_SESSION = array();
}

if(!isset($_SESSION['id']) OR !isset($_SESSION['password'])) {
	kill_session();
	header("location: /index.php?msg=Please log in");
	die;
}

global $me;
if(!$me) {
$me=&new Person($_SESSION['id']);
}

if($_SESSION['password']!=$me->password) {
	kill_session();
	header("location: /index.php?msg=Your password is no longer correct");
	die;
}

if($me->active==0) {
	kill_session();
	header("location: /index.php?msg=Your account has been deactivated.");
	die;
}

if(!$me->canAccessPage_id(pageScript2Id($_SERVER['SCRIPT_NAME']))) {
	header("location: /access_denied.php");
	die;
}
